package com.pigs.pigsordersystem.service.impl;

import com.pigs.pigsordersystem.service.IInventoryService;
import com.pigs.pigsordersystem.entity.InventoryEntity;
import com.pigs.pigsordersystem.mapper.InventoryMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 库存 service 实现类
 * </p>
 *
 * @author Y.yang
 * @since 2020-03-14
 */
@Transactional
@Service
public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, InventoryEntity> implements IInventoryService {

    @Autowired
    private InventoryMapper inventoryMapper;

    /**
     * 修改库存数量
     *
     * @param inventoryNum
     * @param productId
     * @return
     */
    @Override
    public Integer updateInventoryNum(Integer inventoryNum, Integer productId,String inventoryUpdateTime) {
        if (inventoryNum != null && productId != null) {

            Integer flag = inventoryMapper.updateInventoryNum(inventoryNum, productId,inventoryUpdateTime);
            return flag;
        }
        return null;
    }
}
